//
//  BaseView.swift
//  ONESwift
//
//  Created by wangkun on 2017/6/14.
//  Copyright © 2017年 wangkun. All rights reserved.
//

import UIKit
//import JGProgressHUD

class BaseView: UIView {
    
}

extension UIView {
    
//    private func hudShowMain(_ title: String = "", style: JGProgressHUDStyle = .dark, indicator : Bool = false, touchBack: Bool = true, afterDelay: TimeInterval = 0) {
//        var hud : JGProgressHUD!
//        self.subviews.forEach { (view) in
//            if view.isKind(of: JGProgressHUD.classForCoder()) {
//                hud = view as! JGProgressHUD
//            }
//        }
//        if hud == nil {
//            hud = JGProgressHUD(style: style)
//        }
//
//        if !indicator {
//            hud?.indicatorView = nil
//        }
//        if title.count > 0 {
//            hud?.textLabel.text = title
//        }
//        hud?.isUserInteractionEnabled = !touchBack
//        hud?.show(in: self, animated: false)
//
//        if afterDelay > 0.0 {
//            hud?.dismiss(afterDelay: afterDelay)
//        }
//    }
//
//    func hudShow(_ title: String!, style: JGProgressHUDStyle = .dark, afterDelay: TimeInterval = 1) {
//        self.hudShowMain(title, style: style, afterDelay: afterDelay)
//    }
//
//    func hudShowEnabled(title: String, style: JGProgressHUDStyle = .dark, afterDelay: TimeInterval = 1) {
//        self.hudShowMain(title, style: style, touchBack: false, afterDelay: afterDelay)
//    }
//
//    func hudShowEnabled(style: JGProgressHUDStyle = .dark, touchBack: Bool = false) {
//        self.hudShowMain(style: style, indicator: true, touchBack: touchBack)
//    }

    public func hudHide() {
//        self.subviews.forEach { (view) in
//            if view.isKind(of: JGProgressHUD.classForCoder()) {
//                (view as! JGProgressHUD).dismiss(animated: false)
//            }
//        }
    }
    
    func hudShow(_ title: String!) {
        
    }
    
}

//MARK: 获取frame相关属性值
extension UIView {
    var ezSize : CGSize{
        set{
            self.ezWidth = newValue.width
            self.ezHeight = newValue.height
        }
        get{
            return self.frame.size
        }
    }
    
    var ezOrigin : CGPoint{
        get{
            return self.frame.origin
        }
        set{
            self.ezX = newValue.x
            self.ezY = newValue.y
        }
    }
    
    var ezX : CGFloat{
        get{
            return self.ezOrigin.x
        }
        set{
            var f = self.frame
            f.origin.x = newValue
            self.frame = f
        }
    }
    var ezY : CGFloat{
        get{
            return self.ezOrigin.y
        }
        set{
            var f = self.frame
            f.origin.y = newValue
            self.frame = f
        }
    }
    var ezWidth : CGFloat{
        get{
            return self.ezSize.width
        }
        set{
            var f = self.frame
            f.size.width = newValue
            self.frame = f
        }
    }
    var ezHeight : CGFloat{
        get{
            return self.ezSize.height
        }
        set{
            var f = self.frame
            f.size.height = newValue
            self.frame = f
        }
    }
}
